package com.mybpm.core

import com.mybpm.core.definition.ProcessLoadBpmnService
import com.mybpm.core.definition.ProcessLoadService
import grails.util.Holders
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value

class BootStrap {

    @Autowired
    ProcessLoadBpmnService processLoadBpmnService
    @Autowired
    ProcessLoadService processLoadService

    @Value('${bpm.xmlPath:classpath*:bpm}')
    private String bpmPath

    def init = { servletContext ->
        String basePath = Holders.grailsApplication.mainContext.getResources(bpmPath)[0].file.path
        processLoadBpmnService.bpmn2MyBpm(basePath)
        processLoadService.loadXml(basePath)
    }

    def destroy = {
    }
}
